"""
@Author : 合肥一元数智教育科技有限公司
@Date :  2025/2/28 9:37
@Description : 面向对象

通过类的抽取在程序总描述程序员
 1.高级工程师   name   age  salary   write_code
 2.初级工程师   name   age  salary   write_code

1. 继承
   父类和子类
   Engineer  父类
   SeniorEngineer 子类
2. 语法：
       class 子类(父类):
            pass
"""


# 工程师
class Engineer:
    name = None
    age = None
    __salary = None

    def __init__(self, name, age):
        print('--------Engineer init-----------')
        self.name = name
        self.age = age

    # 修改薪资
    def set_salary(self, salary):
        self.__salary = salary

    # 获取薪资
    def get_salary(self):
        return self.__salary


#  高级软件工程师
class SeniorEngineer(Engineer):

    #  编程
    def write_code(self):
        print(f'{self.name}是一个高级工程师,可以编写复杂的程序')


#  创建对象
senior_engineer = SeniorEngineer('Tom', 25)
print(senior_engineer.name)
print(senior_engineer.age)
senior_engineer.set_salary(5000)
print(senior_engineer.get_salary())
senior_engineer.write_code()


#  初级软件工程师
class JuniorEngineer(Engineer):

    #  编程
    def write_code(self):
        print(f'{self.name}是一个初级工程师,可以编写简单的程序')


junior_engineer = JuniorEngineer('jack', 30)
print(junior_engineer.name)
print(junior_engineer.age)
junior_engineer.set_salary(3000)
print(junior_engineer.get_salary())
junior_engineer.write_code()
